#include <iostream>
#include <unistd.h>
#include <signal.h>
#include <sys/types.h>
using namespace std;
void sigcb(int sig)
{
    cout << "sigcb正在处理" << sig << "号信号" << endl;
    while (true)
    {
        sigset_t sg;
        sigpending(&sg);
        for (int i = 31; i >= 1; i--)
        {
            if (sigismember(&sg, i))
                cout << '1';
            else
                cout << "0";
        }
        cout<<endl;
        sleep(1);
    }
}
int main()
{
    struct sigaction act, oact;
    sigemptyset(&act.sa_mask);
    sigaddset(&act.sa_mask, 2);
    sigaddset(&act.sa_mask, 3);
    sigaddset(&act.sa_mask, 4);
    act.sa_handler = sigcb;
    sigaction(SIGINT,&act,&oact);
    while(true)
    {
        cout<<"hello linux!"<<",pid="<<getpid()<<endl;
        sleep(1);
    }
    return 0;
}